{% set pypi_name = 'python-cloudkittyclient' %}
{% set upstream_version = upstream_version('4.1.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Python API for OpenStack Cloudkitty
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
This is a client library for CloudKitty built on the CloudKitty API.
It provides a Python API (the cloudkittyclient module).

%package -n python3-cloudkittyclient
Summary:        Python API for OpenStack Cloudkitty
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('python-keystoneclient') }}
Requires:       {{ py3('python-openstackclient') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}
%if 0%{?suse_version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
%else
# on RDO, update-alternatives is in chkconfig
Requires(post): chkconfig
Requires(postun): chkconfig
%endif

%description -n python3-cloudkittyclient
This is a client library for CloudKitty built on the CloudKitty API.
It provides a Python API (the cloudkittyclient module).

This package contains the Python 3.x module

%package -n {{ py2name() }}-doc
Summary:        Documentation for OpenStack Cloudkitty API client libary
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-svg2pdfconverter') }}

%description -n {{ py2name() }}-doc
This is a client library for CloudKitty built on the CloudKitty API.
It provides a Python API (the cloudkittyclient module).
This package contains the documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg

%build
%{py3_build}

# Build HTML docs and man page
PBR_VERSION={{ upstream_version }} PYTHONPATH=. %sphinx_build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n python3-cloudkittyclient
%doc README.rst
%license LICENSE
%{python3_sitelib}/cloudkittyclient
%{python3_sitelib}/*.egg-info
%{_bindir}/cloudkitty

%files -n {{ py2name() }}-doc
%doc doc/build/html
%license LICENSE

%changelog
